package com.example.service;

import com.example.entity.HistoryThings;
import com.example.entity.HotBooks;
import com.example.mapper.HistoryThingsMapper;
import com.example.mapper.HotBooksMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/*
历史文物业务处理
 */
@Service
public class HistoryThingsService {

    @Resource
    private HistoryThingsMapper historyThingsMapper;

    public void add(HistoryThings historyThings) {
        historyThingsMapper.insert(historyThings);
    }

    public void deleteById(Integer id) {
        historyThingsMapper.deleteById(id);
    }

    public void deleteBatch(List<Integer> ids) {
        for (Integer id : ids){
            this.deleteById(id);
        }
    }

    public void updateById(HistoryThings historyThings) {
        historyThingsMapper.updateById(historyThings);
    }

    public HistoryThings selectById(Integer id) {
        return historyThingsMapper.selectById(id);
    }

    public List<HistoryThings> selectAll(HistoryThings historyThings) {
        return historyThingsMapper.selectAll(historyThings);
    }

    public PageInfo<HistoryThings> selectPage(HistoryThings historyThings, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<HistoryThings> historyThingsList = historyThingsMapper.selectAll(historyThings);
        return PageInfo.of(historyThingsList);
    }
}
